<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<%@ include file="../template/meta.jsp" %>

	<%@ include file="../template/default_styles.jsp" %>

	<%@ include file="../template/default_js.jsp" %>	
 	<script src="/scripts/jquery-1.3.2.js" type="text/javascript"></script>
 	<script src="/scripts/jquery.livequery.js" type="text/javascript"></script>
 	
 	 <script type="text/javascript">  
 	 	                                        
                           
 	 	$(document).ready(function() {

 		   $("#categoryFormSubmit").click(function(e) {
 			  e.preventDefault();
 	
 	 		  $.post("/categories/add", $("#categoryForm").serialize(),
 	 				 function(data){
 	 		   			 $("#categoryList").html(data);
 	 		  			},
 	 	 	 		  "html");
 		   	 		     
 		   });

 			$("#removeCategories a").livequery('click', function(e) {
  	 			e.preventDefault();
  	 			var drop = $(this).attr("href");
  	 			$.post(drop,
  	 				 function(data){
	 		   			 $("#categoryList").html(data);
	 		  			},
	 	 	 		  "html");
  	  	 		 } );	
  	 	   

		 });
	 	
 	</script>  

<title>Merkato - Novas Categorias</title>
	
</head>

<body>
<!-- wrap starts here -->
<div id="wrap">
	<div id="header">

		<%@ include file="../template/header.jsp" %>
	</div>
	

	
	<div id="content-wrap">
		<div id="content">			
		<!-- content-wrap starts here -->
			<%@ include file="../template/adwords.jsp" %>
			
			
			<div id="main"><a name="welcome"></a>
			
			
			<h1>Categorias</h1>
			
			<div class="bar" id="categoryList">
				<p id="removeCategories">
				<c:forEach var="category" items="${categories}">
				 	Nome: ${category.name}
				 <a href="/categories/drop/${category.id}">Remover</a><br/>
				 </c:forEach>
				 </p>
			</div>
			
			
			
			<div id="categoryFormDiv">
				<form id="categoryForm" action="/categories/add" method="post">			
					<p>			
					<label>Nome</label>
					<input name="category.name" value="Name" type="text" size="50" />
					
					<br />	<br />

					<input class="button" type="submit" id="categoryFormSubmit"/>

					</p>		
				</form>		
			</div>
			
			
			<br />
			
			</div>
					
		<!-- content-wrap ends here -->	
		</div>
	</div>

	<%@ include file="../template/footer.jsp" %>
<!-- wrap ends here -->
</div>
</body>
</html>
